% Define a new command to make the command descriptions uniform
\newcommand{\glcommand}[6]{

\subsection{#1}
\leftskip2em #2\\
\\
\leftskip2em \textbf{Syntax:}\\
\\
\leftskip2em \texttt{#3}\\
\\
\leftskip2em \textbf{Parameters:}
\begin{itemize}
\leftskip2em #4
\end{itemize}
\leftskip2em \textbf{Example:}\\
\\
\leftskip2em \texttt{#5}\\
\\
\leftskip2em #6\\
}


% template for a commands copy, paste, use editor's Uncomment command to remove % characters, then replace placeholders
% if you get a missing $ error message, you likely forgot to use \_ instead of _...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\glcommand{COMMAND_NAME}
%{
% DESCRIPTION
% }{
% SYNTAX
% }{
% \item LATEX \item LIST WITH PARAMETERS
% }{
% EXAMPLE
% }{
% COMMENTS FOR EXAMPLE
% }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{The commands}
The following sections describe the commands of the gsas\_language. They are arranged by topic and alphabetically therein. An alphabetic list is also provided. For detailed descriptions of the GSAS functions utilized, refer to the GSAS function and references therein. Introduction to more complex concepts such as constraints, texture etc. are beyond the scope of this document.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Complete list of commands}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{verbatim}
gsas_add_atom
gsas_add_diffuse_scattering
gsas_add_histogram
gsas_add_phase
gsas_calc_bond_length
gsas_change_atom
gsas_change_background
gsas_change_DIFC
gsas_change_Fobs_extraction_flag
gsas_change_lattice
gsas_change_phase_flag
gsas_change_phase_scale
gsas_change_sigma1
gsas_change_sigmas
gsas_change_texture
gsas_constrain_atom
gsas_constrain_phase
gsas_constrain_sigma1
gsas_convert_atom_thermal
gsas_copy_expfile
gsas_delete_atom_constraint
gsas_delete_sigma1_constraint
gsas_done
gsas_exclude_region
gsas_fourier_maps
gsas_initialize
gsas_plot
gsas_plot_bond
gsas_plot_histograms
gsas_plot_overview
gsas_prepare_mem
gsas_read_phase
gsas_refine
gsas_replace_histogram
gsas_simulate_histogram
gsas_single_peak_fits
gsas_single_peak_fits_make_list
gsas_vary_absorption
gsas_vary_atom
gsas_vary_background
gsas_vary_DIFC
gsas_vary_diffuse_scattering
gsas_vary_histogram_scale
gsas_vary_lattice
gsas_vary_phase
gsas_vary_sigma1
gsas_vary_texture
gsas_vary_UVW
gsas_waterfall_add
gsas_waterfall_plot
\end{verbatim}

% Commands that need documenting, delete from here when done...
%
% gsas_calc_bond_length
% gsas_change_DIFC
% gsas_change_phase_flag
% gsas_change_phase_scale
% gsas_constrain_sigma1
% gsas_copy_expfile
% gsas_delete_atom_constraint
% gsas_delete_sigma1_constraint
% gsas_plot
% gsas_plot_bond
% gsas_plot_overview
% gsas_prepare_mem
% gsas_simulate_histogram
% gsas_single_peak_fits
% gsas_single_peak_fits_make_list
% gsas_vary_absorption
% gsas_vary_atom
% gsas_vary_background
% gsas_vary_DIFC
% gsas_vary_diffuse_scattering
% gsas_vary_lattice
% gsas_vary_UVW
% gsas_waterfall_add
% gsas_waterfall_plot

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Beginning and end of refinement}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_copy\_expfile}
{
Copies an existing, presumably successful refinement into a new EXP file. This can be used for sequential refinements to use the previous time/temperature/pressure/strain etc. data file as a template for the next one, assuming that the changes will be small. With this, in longer sequences of refinements one does not need to start from scratch for each run. After the EXP file was copied, use the gsas\_replace\_histogram command to replace the data files referenced in the EXP file, so the EXP file can actually work with the new data. This command replaces gsas\_initialize for subsequent refinements. Therefore, gsas\_initialize must NOT be called for subsequent runs.
}{
gsas\_copy\_expfile <old\_filename> <new\_filename> <new\_title>
}{
\item \texttt{<old\_filename>}: Filename of the old EXP file that is the source. No extension needed, ".EXP" will be added.
\item \texttt{<new\_filename>}: Filename of the new EXP file that will be created. No extension needed, ".EXP" will be added.
\item \texttt{<new\_title>}: Title string for the new refinement which will appear in the head of e.g. histogram plots.
}{
gsas\_copy\_expfile 0TESLA\_BEFORE 1TESLA "Wang, Bi, 1 Tesla magnetic field"\\
gsas\_replace\_histogram "0Tesla\_00deg.gda" "1Tesla\_00deg.gda"\\
gsas\_replace\_histogram "0Tesla\_10deg.gda" "1Tesla\_10deg.gda"\\
gsas\_replace\_histogram "0Tesla\_45deg.gda" "1Tesla\_45deg.gda"\\
}{
Copies an EXP file 0TESLA\_BEFORE.EXP to 1TESLA.EXP and assigns a new title. After that, three data files used in the first EXP file are replaced with the data files of the 2nd EXP file.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_done}
{
This command finishes a refinement. Plots of $\chi^2$, normalized shifts, time per iteration and number of variables are generated using gnuplot and included in the final Acrobat PDF file describing the refinement. Several checks (negative thermal motion, parameters that are zero within their error bars) are performed and added to the refinement report. Temporary files are deleted. If a refinement is aborted and the user wishes to see the overview PDF file, gsas\_done can be issued from the command line.
}{
gsas\_done
}{
\item None.
}{
gsas\_done
}{
This would finish a refinement.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_initialize}
{
This command initializes a new refinement by generating a new GSAS EXP file. It deletes temporary files of possible previous refinements and initializes the documentation file of this refinement.
}{
gsas\_initialize <EXP filename> <title>
}{
\item \texttt{<EXP filename>}: The filename for the GSAS EXP file and assorted files produced by POWPREF, GENLES, etc. Filename must not have an extension. Filename will be automatically converted to capital letters since GSAS expects capital letters on UNIX platforms.
\item \texttt{<title>}: An arbitrary title to be displayed in the POWPLOT plots etc.
}{
gsas\_initialize SIO2\_FURNACE\_\$1C "SiO2, furnace, \$1C"
}{
When a script with this line is called with a parameter 100, e.g. the GSAS data file for a run at  100C, 
named 100C.gda, the \$1 occurences will be replaced with "100" by bash, generating a EXP filename 
SIO2\_FURNACE\_100C.EXP with a run title label "SiO2, furnace, 100C".
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_replace\_histogram}
{
Replaces all references to a filename with a new filename in the current EXP file. This is typically done after a gsas\_copy\_expfile command, using a previous refinement as a template for a new refinement. Since the extension for data files in GSAS is not fixed, the extension of the data file has to be provided. This runs a simple text search and replace operation on the current EXP file, so in principle it can be used for other purposes, such as replacing instrument parameter files. 
}{
gsas\_replace\_histogram <old\_filename> <new\_filename>
}{
\item \texttt{<old\_filename>}: Filename of the old data file that needs to be replaced.
\item \texttt{<new\_filename>}: Filename of the new data file that will be referenced after this operation.
}{
See example for gsas\_copy\_expfile.
}{
See example for gsas\_copy\_expfile.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Adding histograms and phases}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_add\_atom}
{
Adds an atom to an existing phase of the refinement. The phase can be either added using the gsas\_read\_phase or gsas\_add\_phase commands.
}{
gsas\_add\_atom <phase number> "<GSAS atom parameter sequence>"
}{
\item \texttt{<phase number>}: The number of the phase in the main EXP file to which this atom is to be added.
\item GSAS atom parameter sequence: Space-separated sequence of element symbol, x, y, z coordinates, site occupation factor, atom label (or forward slash for default), thermal motion flag and value of thermal motion parameter(s). This is the same sequence a user would provide following a "i n" command in the atoms menu in EXPEDT.
}{
gsas\_add\_atom 1 "NI 0 0 0 1 / i 0.004"
}{
This would add a nickel atom to phase 1 on position x=0, y=0, z=0 that is fully occuped (FRAC=1) with the default name that GSAS assigns (the element symbol plus the number of the atom in the sequence). The atom would have isotropic thermal motion with a starting value of $U_{iso}=0.004$.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_add\_histogram}
{
Adds a phase to the refinement by adding the phase information "manually" rather than loading all information from a file. Similar to the addition in GSAS, no atom information is provided in this step (see gsas\_add\_atom). The existence of the space group and the lattice parameters in the main EXP file is verified after adding this information. Existence of the data and the instrument parameter file are checked before the insertion of the histogram data is attempted. Existence of the histogram data filename in the EXP file is checked after the insertion. This command may be used multiple times if multiple histograms are required for a refinement.
}{
gsas\_add\_histogram <data\_file> <par\_file> <bank> <min\_d> <max\_d>
}{
\item \texttt{<datafile>}: Filename of the data file with the histogram data to be loaded (GSAS data file format).
\item \texttt{<par\_file>}: Filename of the instrument parameter file required to interpret the histogram data.
\item \texttt{<bank>}: Bank number of the histogram to be read.
\item \texttt{<min\_d>, <max\_d>}: Minimum and maximum d-spacing to be used for this histogram.
}{
gsas\_add\_histogram nickel.raw inst\_tof.prm 2 0.25 3
}{
This would add histogram number 2 from the GSAS data file nickel.raw, using the GSAS instrument parameter file inst\_tof.prm. The minimum d-spacing for this histogram would be set to 0.25\AA\ and the upper d-spacing limit would be 3\AA.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_add\_phase}
{
Adds a phase to the refinement by adding the phase information "manually" rather than loading all information from a file. Similar to the addition in GSAS, no atom information is provided in this step (see gsas\_add\_atom). The existence of the space group and the lattice parameters in the main EXP file is verified after adding this information.
}{
gsas\_add\_phase "<phase name>" "<space group>" "lattice parameters"
}{
\item \texttt{phase name}: The identifier for the phase in GSAS.
\item \texttt{space group}: The space group of the crystal structure.
\item \texttt{lattice parameters}: The lattice parameters for the crystal structure.
}{
gsas\_add\_phase "Nickel" "f m -3 m" "3.5234"
}{
This will add a phase with the label \texttt{Nickel} that has the cubic space group $Fm\bar{3}m$ and a lattice parameter of 3.5234\AA.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_exclude\_region}
{
Excludes a region (in the native x-axis unit of the data, i.e. time-of-flight or 2$\theta$) from the refinement. To convert from d-spacing to the native x-axis unit, either convert using the equations in the manual or use the EXPEDT minimum d-spacing function (enter the d-spacing to converted, read the value in the native x-axis unit, then enter the true minimum again). Make sure that an extra excluded region does not overlap with the upper or lower limit, this will cause instabilties as e.g. background functions to diverge.
}{
gsas\_exclude\_region <histogram> <from> <to>
}{
\item \texttt{histogram}: The histogram number for which the excluded region is to be inserted.
\item \texttt{from}: The lower limit of the excluded region in native units of the x-axis.
\item \texttt{to}: The upper limit of the excluded region in native units of the x-axis.
}{
gsas\_exclude\_region 1 16 18
}{
Excludes for histogram 1 the region from 16 to 17, either 2$\theta$ or time-of-flight in ms. For the HIPPO neutron time-of-flight diffractometer, this command would exclude a background generated from the adjacent WNR facility from around 16-18 ms (1/60 of a second=16.6 ms) in backscattering detector bank 1.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_read\_phase}
{
Adds a phase to the refinement by loading a crystal structure from a file. The file with the crystal structure information has to be in GSAS format, CIF files are currently not supported. The existence of the phase file is checked before loading is attempted. The number of the phase during the refinement is determined by the sequence by which the phases are added to the refinement.
}{
gsas\_read\_phase <filename> <phase number>
}{
\item \texttt{filename}: The name of the file (with extension, e.g. \texttt{.exp}) from which the crystal structure information is to be read.
\item \texttt{phase number}: The number of the phase in the GSAS EXP file, typically 1.
}{
gsas\_read\_phase "Boron\_beta\_68106.exp" 1
}{
This would read phase information (lattice parameters, space group, atom parameters such as positions and thermal motion parameters) from a file name \texttt{Boron\_beta\_68106.exp} (case sensitive!). In that file, phase number 1 would be read.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Crystal structure refinement}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_add\_diffuse\_scattering}
{
This function allows to use the diffuse scattering function to model a contribution to the "background" by e.g. an amorphous phase.
}{
gsas\_add\_diffuse\_scattering <histogram> <function type> <amplitude> <radius> <Uiso> <atom type 1> <atom type 2> 
}{
\item \texttt{<histogram>}: The histogram for which the diffuse scattering term will be added.
\item \texttt{<function type>}: The diffuse scattering function to be used. Possible options are "1" for diffuse scattering from substitional disorder (e.g. an alloy), "2" for positional disorder (e.g. a glass), and "3" for diffuse scattering caused by vibrational correlation. See the GSAS manual (page 131) for more information.
\item \texttt{<amplitude>}: The starting value for the amplitude for the particular diffuse scattering term. "1" typically is a good starting value.
\item \texttt{<radius>}: The starting value for radius or atomic distance for the particular diffuse scattering term.
\item \texttt{<Uiso>}: The starting value for the isotropic thermal motion parameter for the atoms of this particular diffuse scattering term.
\item \texttt{<atom type 1>}: The first atom of the pair, has to be a valid element in GSAS.
\item \texttt{<atom type 2>}: The second atom of the pair, has to be a valid element in GSAS.
}{
EXAMPLE
}{
COMMENTS FOR EXAMPLE
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_change\_atom}
{
This command is used to change values of atom parameters, such as position or thermal motion, but also the atom type to change the element/isotope for a given atom or atom sequence. Using the EXPEDT convention to address several atoms at once, e.g. in the sequence of atoms within a phase or by their element type, multiple atoms can be affected at once.
}{
gsas\_change\_atom <phase> <atom range> <parameter name> <value>
}{
\item \texttt{phase}: The number of the phase to which the atoms belong that need to be changed.
\item \texttt{atom range}: An atom range, e.g. the number of a single atom, a sequence in the GSAS atom list of the phase, or a specific type (element or isotope). This parameter can be anything EXPEDT understands.
\item \texttt{parameter name}: The parameter name, one of \texttt{X, Y, Z, UISO, FRAC, U11, U22, U33, U12, U13, U23, TYPE, NAME}.
\item \texttt{value}: The new value for the parameter of the atoms addressed with the previous parameters. 
}{
gsas\_change\_atom 1 NI UISO 0.004
}{
This would change the isotropic thermal motion parameter \texttt{UISO} of all atoms of the type \texttt{NI} in phase 1 to 0.004\AA$^2$.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_change\_background}
{
This command changes the type of the background function used for a given histogram and the number of parameters for that function.
}{
gsas\_change\_background <histogram> <background function> <number of parameters>
}{
\item \texttt{histogram}: The number of the histogram for which the background will be changed.
\item \texttt{background function}: The number of the function to be used to describe the background in this histogram. Currently, valid numbers are 1, 2, 4, 5, 6, 7, and 8 (see page 129 in the 2004 or 'modern' GSAS manual).
\item \texttt{number of parameters}: The number of parameters or coefficients to be used for the selected background function. GSAS supports up to 36 parameters, typically much less are sufficient.
}{
gsas\_change\_background 2 1 16
}{
Changes the background of histogram 2 to GSAS background function number 1 with 16 parameters.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_change\_Fobs\_extraction\_flag}
{
This command allows to change the way the observed structure factors are extracted from the measured data. This allows essentially to switch between 
\begin{itemize}
\item Rietveld mode: All peak intensities in the model are constrained by the atomic position, thermal motion, texture etc.
\item Le Bail mode: Each peak intensity is an independent variable, like in a single peak fit, but with all peak positions constrained by the space group and lattice parameters and peak profile parameters constrained by the implemented functions for them.
\end{itemize}
While Rietveld mode is obviously useful to perform crystal structure refinements, Le Bail mode is useful when a good structural model is not available. Examples are reliable extraction of lattice parameters in the presence of texture or initialization of lattice and peak profile parameters during the early stages of a crystal structure refinement such that they can be fixed during refinement of intensity dependent parameters later to reduce the number of parameters varied and make the fit more stable. Since in Le Bail mode all peak intensities are independent, all peak intensity dependent parameters such as atomic positions, thermal motion and texture and also the histogram and phase scale factors need to be fixed. Otherwise divergence will occur. Also, each run of POWPREF will reset the peak intensities to their initial values. It is therefore advisable to have lattice parameters etc. fixed when starting the refinement. Once the intensities are properly initialized, lattice parameters can be refined but then POWPREF should only be re-run if they are fixed again.

The peak intensities are not part of the variable set counted in the "final variable sum((shift/esd)**2)" in GENLES. Therefore, a stop in reduction of the "Reduced CHI**2" is a better indicator as to when convergence was achieved. Oscillations are frequent in Le Bail refinement and damping might need to be included. Typically, fixing the refined parameters, then running POWPREF with background only followed by refining the previously varied parameters again further reduces the CHISQ.
}{
gsas\_change\_Fobs\_extraction\_flag <histogram> <extraction flags>
}{
\item \texttt{histogram}: The number of the histogram for which the extraction flags should be changed.
\item \texttt{extraction flags}: Same as in EXPEDT: "n" for Rietveld, "y n" for Le Bail with starting intensities weighed by the current structural model, and "y y" with initial intensities all set to 1.0. For multiple phases, the right number of "n", "y n", or "y y" has to be added into a single string enclosed by double quotes, e.g. "y n y n y n" for setting three phases to a weighed Le Bail mode.
}{
gsas\_change\_Fobs\_extraction\_flag 1 "y n"
}{
This command will set the extraction flags for histogram number 1 to Le Bail mode with a model-based initial intensity guess.
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_change\_lattice}
{
Changes the lattice parameters of a given phase. This might be necessary for instance when the parameters from the phase file read with gsas\_read\_phase do not match the experimental data, e.g. due to differences in the chemistry.
}{
gsas\_change\_lattice <phase> <lattice parameters>
}{
\item \texttt{phase}: The number of the phase for which the lattice parameters are changed.
\item \texttt{lattice parameters}: The new lattice parameters. The number of parameters depends on the space-group of the phase, e.g. one for cubic, two for hexagonal, or six for triclinic crystal structures. The parameters are input as in GSAS, e.g. first $a$, then $c$ for hexagonal, or in the sequence $a, b, c, \alpha, \beta, \gamma$ for triclinic phases. The parameters can be either given as individual numbers, or as a single string encapsulated in double-quotes.
}{
gsas\_change\_lattice 1 3.14 11.05 OR
gsas\_change\_lattice 1 "3.14 11.05"
}{
Sets the lattice parameters of phase 1 to 3.14A and 11.05A. Since there are two parameters given, the phase is either hexagonal, tetragonal, or rhombohedral.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_change\_profile\_cutoff}
{
Changes the profile cut-off for which the peak profile of a given peak is computed. Peak profiles are defined from $-\infty$ to $+\infty$. To keep a finite computation time, the peak profile computation is cut-off at a certain fraction of the maximum peak intensity. In older instrument parameter files or for low statistics data, this value can be $1.00\%$ and one might wish to change it to $0.10\%$.
}{
gsas\_change\_profile\_cutoff <histogram> <phase> <cut-off value>
}{
\item \texttt{histogram}: The number of the histogram for which the cut-off should be changed.
\item \texttt{phase}: The number of the phase for which the cut-off should be changed.
\item \texttt{cut-off value}: The new value for the peak cut-off intensity, in a per-cent value of maximum intensity.
}{
gsas\_change\_profile\_cutoff 2 1 0.1
}{
Changes the peak cut-off value for histogram 2, phase 1, to $0.1\%$.
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_change\_texture}
{
Changes for a given phase the order of the spherical harmonics representation of the crystal orientation distribution function (ODF - the texture or preferred orientation of a phase) and the sample symmetry of the texture. In general, this function should only be used when sufficient sample directions are probed in a multi-histogram refinement. If this is not the case, any intensity-dependent parameters (atomic structure, phase fractions) will be affected and this may lead to false results. Imposing a sample symmetry will reduce the number of required sample directions/histogram, however, one may wish to verify the existence of such symmetry independently, i.e. with a full texture measurement. In case a symmetry is imposed, the center of symmetry, e.g. fiber axis, has to be in the center of the resulting pole figures and the sample orientation angles may have to be changed.
}{
gsas\_change\_texture <phase> <order> <symmetry>
}{
\item \texttt{phase}: The number of the phase for which to change the texture description.
\item \texttt{order}: The order of spherical harmonics to be used, must be an even number.
\item \texttt{symmetry}: The sample symmetry of the spherical harmonics description of the ODF. Valid numbers are 0 (cylindrical symmetry or single fiber texture), 1 (triclinic or no symmetry), 2 (2/m or shear texture), or mmm (orthorhombic or rolling texture).
}{
gsas\_change\_texture 1 8 1
}{
Changes the ODF description for phase 1 to an 8th order spherical harmonics series expansion with no sample symmetry.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_constrain\_atom}
{
This command is used to set a given atom parameter (e.g. occupancy, position, thermal motion) for different atoms in a phase to be constrained together during refinements.  By default, this would set the different atom parameters to vary together (for example, if you wanted the thermal motion of atoms 2 and 3 to be constrained together since they are crystallographically similar and the refinement diverges otherwise).  Note that if you want two atom parameters to be equal, they must start out equal before they are varied when constrained together, otherwise they will vary proportional to one another.  In the case of constraining the occupancy, the values will be constrained such that they alway add up to the sum of the their starting occupancies (usually 1). More complex and multi-phase constraints, i.e. constraints affecting atoms from different phases, are also possible. This allows for instance in a mix of two oxides to constrain the oxygen atoms together. Note that differently from the \texttt{gsas\_change\_atom} etc. commands addressing by atomic species is not allowed, whereas sequences, e.g. \texttt{1:3}, are possible.
}{
gsas\_constrain\_atom <phase> <atom prm> <atom 1> <atom 2> <atom 3>...\\
\\
OR
\\
gsas\_constrain\_atom multi "<constraint term 1>" "<constraint term 2>" ...
}{
\item \texttt{phase}:  Phase number for which atom parameters should be constrained. If \texttt{phase} is \texttt{multi}, constraints over multiple phases may be defined. In this case all following parameters will have to be entries (in quotes or double-quotes) as given during definition of these constraints in EXPEDT (see example).
\item \texttt{atom prm}: Atom parameters which should be constrained, one of \texttt{X, Y, Z, UISO, FRAC, U11, U22, U33, U12, U13, U23}.
\item \texttt{atom i}:  Atom numbers of the atom set that should be constrained, listed separately.
\item \texttt{constraint term i}:  A constraint term as required by EXPEDT consisting of phase number, variable identifier \texttt{atom prm}, atom or atom sequence and multiplier.
}{
gsas\_constrain\_atom 1 U11 2 3 \\
gsas\_constrain\_atom multi "1 UISO 1:3 1" "2 UISO 1 1"
}{
The first example sets the thermal motion parameter U11 for atoms 2 and 3 in phase 1 to be constrained together. The second example constrains the Uiso of atoms 1 to 3 of phase with a multiplier of 1 to the atom 1 of phase 2, also with a multiplier of 1 (the multiplier is the last entry).
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_constrain\_phase}
{
Constrains a phase to have a constant weight fraction in all histograms.  In most cases, this should be set before varying a phase during refinements. Excemptions might be refinements of histograms originating from different instruments and only some of them show an extra phase.
}{
gsas\_constrain\_phase <phase>
}{
\item \texttt{phase}:  Phase number for which weight fraction should be constrained.
}{
gsas\_constrain\_phase 2
}{
Sets the weight fraction of phase 2 to be equal in all histograms. 
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_convert\_atom\_thermal}
{
Converts thermal motion parameters of atoms from isotropic (UISO) to anisotropic (U11, U22, U33, etc) or vice versa.
}{
gsas\_convert\_atom\_thermal <phase> <atom range> <flag>
}{
\item \texttt{phase}: Number of the phase for which parameters should be changed.
\item \texttt{atom range}: Atom(s) for which thermal factors should be changed.  This is a valid GSAS atom range, e.g. the number of a single atom, a sequence in the GSAS atom list of the phase, or a specific type (element or isotope). This parameter can be anything EXPEDT understands. \texttt{<t>}, \texttt{<s>} or \texttt{<s1:s2>}
\item \texttt{flag}:  Flag for thermal factors: \texttt{i} for isotropic or \texttt{a} for anisotropic.
}{
gsas\_convert\_atom\_thermal 1 1:4 a
}{
This would convert the thermal motion parameters to anisotropic for atoms 1, 2, 3 and 4 of phase 1.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_refine}
{
Performs the actual refinement by calling POWPREF and GENLES for a given number of refinement cycles. Each call to this command adds a section to the refinement protocol generated at the very end of the refinement.
}{
gsas\_refine <cycles> [noplot] [nopowpref]
}{
\item \texttt{cycles}: The number of refinement cycles in GENLES to be performed.
\item \texttt{noplot}: If the word "noplot" is added after the number of cycles, the time-consuming generation of plots using POWPLOT is skipped.
\item \texttt{noplot}: If the word "nopowpref" is added after the number of cycles, running of \texttt{powpref} will be skipped. This is useful during Le Bail fits during which re-setting the peak intensities by \texttt{powpref} may lead to divergence.
}{
gsas\_refine 2 noplot
}{
Performs a least-squares cycle by calling POWPREF, then changing the number of refinement cycles to 2 and calling GENLES. Plots of the fit will not be generated for the overview file.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_vary\_DIFC}
{
Changes the refinement flags for the diffractometer constants (DIFCs) for a given histogram. This is needed to e.g. calibrate an instrument or sample environment or to accomodate sample misalignment.
}{
gsas\_vary\_DIFC <histogram> <code>
}{
\item \texttt{histogram}: The number of the histogram for which the new refinement flags are given.
\item \texttt{code}: The code(s) of the diffractometer constants that should be varied. These depend on the instrument type, e.g. for neutron time-of-flight they are \texttt{C} for \texttt{DIFC}, \texttt{A} for \texttt{DIFA}, and \texttt{Z} for \texttt{ZERO}. The codes for other instrument types can be queried with \texttt{expedt}, options \texttt{k l o c v}. Combinations are possible, e.g. \texttt{CA} would vary \texttt{DIFC} and \texttt{DIFA} in the above example. To fix diffractometer constants use \texttt{" "} (double quotes with space inbetween) as code.
}{
gsas\_vary\_DIFC 1 C
\newline
gsas\_vary\_DIFC 2 " "
}{
Turns on variation of \texttt{DIFC} for histogram number 1 and fixes all diffractometer constants for histogram 2.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_vary\_histogram\_scale}
{
Changes the variation flag for the histogram scale factor. In general, the histogram scale should be varied and is so by default in a new refinement. However, in Le Bail mode all intensity changing parameters should be fixed to avoid zero-matrix elements (message "... Columns of the N Column matrix are 0.0") and divergence.
}{
gsas\_vary\_histogram\_scale <histogram> <variation flag>
}{
\item \texttt{histogram}: The number of the histogram for which the new refinement flag is given.
\item \texttt{variation flag}: The flag, either "y" to vary the scale or "n" to fix it.
}{
gsas\_vary\_histogram\_scale 1 n
}{
Fixes the histogram scale for histogram 1.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_vary\_phase}
{
Sets refinement flag for weight fraction of specified phase.  
}{
gsas\_vary\_phase <phase\#> <flag>
}{
\item \texttt{phase\#}:  Number of phase for which weight fraction should be varied or fixed. 
\item \texttt{flag}: Variation flag: \texttt{<y>} to vary or \texttt{<n>} to fix; if no flag then assume \texttt{<y>}.  
}{
gsas\_vary\_phase 2 y
}{
Sets refinement flag for phase 2 to ``y'' (vary it).
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_vary\_profile\_parameters}
{
This is the most common command to vary peak profile parameters. For some commonly used peak profiles, special commands are available to vary common parameters such as $\sigma_1$ for neutron time-of-flight data. For the general case, i.e. to vary any parameter, this command can be used.
}{
gsas\_vary\_profile\_parameters <histogram> <phase> <flags>
}{
\item \texttt{histogram}: The number of the histogram for which the flags should be set.
\item \texttt{phase}: The number of the phase for which the flags should be set.
\item \texttt{flags}: The flags, either in sets of flags like "n y n", or as a single sequence exactly as queried by EXPEDT, e.g. "/ / n y n / / /" to not change the first and second set of flags, then change to not varying, varying and not varying the next three parameters, and leaving the rest untouched. The sequence of parameters depends on the profile function used and if in doubt needs to be tried by starting EXPEDT.
}{
gsas\_vary\_profile\_parameters 1 1 "n n" "y y" "y y y" "n n n"
}{
Change the variation for peak profile parameters of phase 1 in histogram 1.
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_vary\_texture}
{
Changes the variation and damping flags for the spherical harmonics description of the ODF for a given phase.
}{
gsas\_vary\_texture <phase> <variation flag> <damping>
}{
\item \texttt{phase}:  Number of phase for which the ODF/texture should be varied or fixed. 
\item \texttt{variation flag}: Variation flag: \texttt{<y>} to vary or \texttt{<n>} to fix.  
\item \texttt{damping}: The damping flag, a number between 0 (no damping) and 9 (maximal damping). This parameter is optional - if not given, the previous damping flag persists (no damping by default).
}{
gsas\_vary\_texture 1 n
}{
Fixes the texture for phase 1.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Neutron time-of-flight specific}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_change\_sigmas}
{
Changes the values for the three peak width parameters of neutron time-of-flight profile function number 1. This function can be used to reset the values if needed or initialize to a specific value in case constraints between peak width parameters are introduced that require a certain ratio, e.g. that they are the same, between peak width parameters of different histograms or phases.
}{
gsas\_change\_sigmas <histogram> <phase> <sigma0> <sigma1> <sigma2>
}{
\item \texttt{histogram}: The number of the histogram for which the value of the $\sigma$ parameters should be changed.
\item \texttt{phase}: The number of the phase for which the value of the $\sigma$ parameters should be changed.
\item \texttt{sigma0,sigma1,sigma2}: The value for each of the three parameters.
}{
gsas\_change\_sigmas 2 1 0 60 0
}{
Changes the peak width parameters $\sigma_0$, $\sigma_1$, and $\sigma_2$ for histogram 2, phase number 1, to 0, 60, and 0, respectively.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_vary\_sigma1}
{
Variation of the $\sigma_1$ peak-width parameter for neutron time-of-flight data using profile function number 1, the default for many neutron time-of-flight diffractometers.
}{
gsas\_vary\_sigma1 <histogram> <phase> <flag> <damping>
}{
\item \texttt{histogram}: The number of the histogram for which the $\sigma_1$ parameter should be varied.
\item \texttt{phase}: The number of the phase for which the $\sigma_1$ parameter should be varied.
\item \texttt{flag}: The refinement flag, either \texttt{y} for varyiable or \texttt{n} for fixed.
\item \texttt{damping}: The damping flag, a number between 0 (no damping) and 9 (maximal damping).
}{
gsas\_vary\_sigma1 2 1 y 4
}{
Varies (\texttt{y}) the $\sigma_1$ parameter for histogram 2, phase 1 and damps the variation with a damping factor of 4.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Generating extra infomation}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_fourier\_maps}
{
Generates all Fourier maps defined in GSAS: Calculated (FCLC), observed (experimental, FOBS) and difference Fourier map (DELF) as well as a 2FDF map (the Fourier map $2F_o-F_c$) . After generation, the Fourier maps are output in \texttt{.grd} format, which can be imported for instance into Koichi Momma's software VESTA for viewing Fourier maps in 3D together with the crystal structure for comparison and e.g. identification of potentially missing atoms. You may download VESTA from

\url{http://www.geocities.jp/kmo_mma/crystal/en/vesta.html}

Open the grd file in VESTA. To modify the contour levels in VESTA, go to Objects -- Properties -– Isosurfaces, select an isosurface in the list (roughly center of the dialog box, next to new, delete and clear buttons) and modify the level, color etc. above the list. In order to also plot the atoms, go to Edit Data -– Structure Parameters and click on import (bottom right) and read the EXP file with the current crystal structure. If you save a VESTA file with a .grd and your current imported EXP file, you may just re-open the VESTA file to obtain updated structure plots after refinement and/or generation of Fourier plots have run again.
}{
gsas\_fourier\_maps <section>
}{
\item \texttt{section}: The type of section for the Fourier map, x, y, or z. The default (if this parameter is not given) is z.
}{
gsas\_fourier\_maps
}{
This will simply generate all Fourier maps in \texttt{.grd} format.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\glcommand{gsas\_plot\_histograms}
{
Plots all histograms of a GSAS refinement. Contrary to the main refinement protocol, no error plots are given. This particularly useful for multi-histogram refinements, e.g. for texture analysis, as it allows to more easily inspect all histograms. The output file is always \texttt{all\_hist.pdf}, which may be renamed to inspect a longer refinement at various steps after the refinement is done (or crashed...).
}{
gsas\_plot\_histograms
}{
\item This function has no parameters.
}{
gsas\_plot\_histograms
mv all\_hist.pdf After8thOrder.pdf
}{
Generates all plots of the current refinement and then renames the resulting PDF file to \texttt{After8thOrder.pdf} to indicate at which step the "snapshot" was taken.
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Plotting of results}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


